﻿using System;
using UnityEngine;



namespace MyLib
{
    public class MyClass
    {


        //static Vector3 a;
        static float i = 0, j = 0;
        
        public static void move(GameObject obj)
        {

            //   if (!Input.anyKey)
            //{
            //    obj.transform.parent.eulerAngles = a;
            //   //transform.eulerAngles = a;
            //    i = 0;
            //    j = 0;
            //}
            //else
            //{
            if (Input.GetMouseButton(0))
            {
               
                if (Mathf.Abs(i) < 60.0f)
                {
                    float x = Input.GetAxis("Mouse Y");

                    i += x * Time.deltaTime;


                }
                if (Mathf.Abs(j) < 60f)
                {
                    float y = Input.GetAxis("Mouse X");
                    j -= y * Time.deltaTime;

                }

                //  transform.rotation = Quaternion.Euler(Mathf.Clamp(i * 100, -60, 60), Mathf.Clamp(j * 100, -60, 60), 0);
                obj.transform.parent.rotation = Quaternion.Euler(Mathf.Clamp(i * 200, -60, 60), Mathf.Clamp(j * 200, -60, 60), 0);
                Debug.Log(i); Debug.Log(j);
            }
            
        }
        public static void rotate(GameObject obj)
        {
            if (Input.GetMouseButton(0))
            {

                float x = Input.GetAxis("Mouse Y");

                i += x * Time.deltaTime;

                float y = Input.GetAxis("Mouse X");
                j -= y * Time.deltaTime;

                //  transform.rotation = Quaternion.Euler(i*1000, j*1000, 0);
                obj.transform.rotation = Quaternion.Euler(i * 1000, j * 1000, 0);

            }

        }

        public static void yrotate(GameObject obj)
        {
            if (Input.GetMouseButton(0))
            {

                float x = Input.GetAxis("Mouse Y");

                j += x * Time.deltaTime;

                float y = Input.GetAxis("Mouse X");
                j -= y * Time.deltaTime;

                //  transform.rotation = Quaternion.Euler(i*1000, j*1000, 0);
                obj.transform.rotation = Quaternion.Euler(0, j * 1000, 0);

            }
        }

        public static void dropdownchange(Transform[] obj, string str)
        {
            for (int i = 0; i < obj.Length; i++)
            {
                for (int j = 0; j < obj.Length; j++)
                {
                    obj[i].GetChild(j).gameObject.SetActive(false);
                }
                if (str == "丙氨酸 Ala")
                {
                    obj[i].GetChild(0).gameObject.SetActive(true);
                }
                if (str == "亮氨酸 Leu")
                {
                    obj[i].GetChild(1).gameObject.SetActive(true);

                }
                if (str == "甘氨酸 Gly")
                {
                    obj[i].GetChild(2).gameObject.SetActive(true);

                }
                if (str == "脯氨酸 Pro")
                {
                    obj[i].GetChild(3).gameObject.SetActive(true);

                }
                if (str == "苯丙氨酸 Phe")
                {
                    obj[i].GetChild(4).gameObject.SetActive(true);

                }
                if (str == "赖氨酸 Lys")
                {
                    obj[i].GetChild(5).gameObject.SetActive(true);

                }
            }
        }

        //public static void togglechange(Transform[] obj,bool value,int i)
        //{
        //    for ( i = 0; i < obj.Length; i++)
        //    {
        //        if (value==true)
        //        {
        //            obj[i].gameObject.SetActive(true);
        //        }
        //        else
        //        {
        //            obj[i].gameObject.SetActive(false);
        //        }
        //    }
        //}
    }
}
